﻿#ifndef SERIALTHREAD_H
#define SERIALTHREAD_H

#include <QThread>
#include <ctime>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QtCore/QTimer>
#include "../../include/serialpack.h"

class SerialThread : public QThread
{
    Q_OBJECT
public:
    SerialThread();
    ~SerialThread();

    QSerialPort* m_serial = nullptr;

    bool open(QString serialName, int baudRate = 9600);
    void readData();
    void delay();
    void close();

    QStringList scanSerial();
    QTimer* m_timer;

signals:
    void sig_serialData(const SerialPack&);

public slots:
    void slt_writeData(const QByteArray&);

protected:
    virtual void run() override;


};

#endif // SERIALTHREAD_H
